package org.jumiz.lowcode.core.sys.config.service;

import org.jumiz.lowcode.core.sys.config.entity.LowcodeConfigTable;
import org.jumiz.lowcode.core.sys.config.entity.LowcodeConfigTableColumn;
import org.jumiz.lowcode.core.sys.config.entity.LowcodeConfigTableLog;
import org.jumiz.lowcode.core.sys.config.repository.LowcodeConfigTableColumnRepository;
import org.jumiz.lowcode.core.sys.config.repository.LowcodeConfigTableLogRepository;
import org.jumiz.lowcode.core.sys.config.repository.LowcodeConfigTableRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LowcodeConfigTableService {

    @Resource
    private LowcodeConfigTableRepository lowcodeConfigTableRepository;

    @Resource
    private LowcodeConfigTableColumnRepository lowcodeConfigTableColumnRepository;

    @Resource
    private LowcodeConfigTableLogRepository lowcodeConfigTableLogRepository;

    @Transactional(rollbackFor = Exception.class)
    public void save(LowcodeConfigTable table, List<LowcodeConfigTableColumn> columns, LowcodeConfigTableLog tableLog) {
        lowcodeConfigTableRepository.save(table);
        lowcodeConfigTableColumnRepository.saveAll(columns);


    }

}
